import 'package:ccshop/ui/widget/order/OrderList.dart';
import 'package:flutter/material.dart';

/**
 * 全部订单
 */
class AllOrderPage extends StatefulWidget {

  final _index;

  AllOrderPage(this._index);

  @override
  _AllOrderPageState createState() => _AllOrderPageState(_index);
}

class _AllOrderPageState extends State<AllOrderPage>
    with SingleTickerProviderStateMixin {
  int _index; // 选中的下标
  TabController _defaultTabController;

  _AllOrderPageState(int _index) {
    this._index = _index;
  }

  List<Tab> allOrderTab = [
    Tab(
      text: "全部",
    ),
    Tab(
      text: "待付款",
    ),
    Tab(
      text: "待配送",
    ),
    Tab(
      text: "配送中",
    ),
    Tab(
      text: "待提货",
    ),
    Tab(
      text: "已提货",
    ),
  ];
  List<Widget> allOrderContent = List();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _defaultTabController =
        TabController(length: allOrderTab.length, vsync: this, initialIndex: _index);
    allOrderTab.forEach((element) {
      allOrderContent.add(OrderList());
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: InkWell(
          onTap: (){
            Navigator.pop(context);
          },
          child: Icon(
            Icons.arrow_back_ios,
            color: Colors.white,
          ),
        ),
        title: Text("我的订单"),
        centerTitle: true,
        bottom: TabBar(
          labelStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
          isScrollable: true,
          indicatorColor: Colors.white,
          indicatorSize: TabBarIndicatorSize.label,
          controller: _defaultTabController,
          tabs: allOrderTab,
        ),
      ),
      body: TabBarView(
        controller: _defaultTabController,
        children: allOrderContent,
      ),
    );
  }
}
